package br.com.vti.sisp_sicrim.antigo.controller.relatorios;

import java.io.FileNotFoundException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import net.sf.jasperreports.engine.JRException;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.interceptor.download.InputStreamDownload;
import br.com.vti.sisp_sicrim.antigo.util.Relatorios;
import br.com.vti.sisp_sicrim.antigo.util.Sessao;

/**
 * Classe responsavel por encapsular o tratamento e as consistencias da tela Estte131Report
 * 
 * @author Incode - Data: jun/2014
 * 
 */
public class Estte131Report {
	private int dataCorrente;
	private int dtini;
	private int dtfim;
	private String horaCorrente;
	private int[][] tra1 = new int[8][101];
	private int[] mat1 = new int[101];
	private int[] tot0 = new int[8];
	private Result result;
	private Sessao sessao;
	private Relatorios report; // Classes views
	private int matricula = 0;
	private int inclusoes = 0;
	private int alteracoes = 0;
	private int correcoes = 0;
	private int baixas = 0;
	private int ident = 0;
	private int prontuario = 0;
	private int total = 0;

	private int inclusoest = 0;
	private int alteracoest = 0;
	private int correcoest = 0;
	private int baixast = 0;
	private int identt = 0;
	private int prontuariot = 0;
	private int totalt = 0;

	// Classes includes
	public Estte131Report() throws JRException {
		inicializar();
	}

	public Estte131Report(Sessao sessao) throws JRException {
		this.sessao = sessao;
		inicializar();
	}

	public void inicializar() throws JRException {
		report = new Relatorios();
		dataCorrente = 0;
		dtini = 0;
		dtfim = 0;
		mat1 = new int[101];
		tra1 = new int[8][101];
		tot0 = new int[8];
		horaCorrente = new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()); // *TIMX
		report.setNumeroRel(1, "D");
		{
			report.setNumeroLinhaRel(1, 3);
			{
				report.adicionaCampo(2, 3, "lit_2_3", "C", "", "SSP");
				report.adicionaCampo(10, 43, "lit_10_43", "C", "", "- SECRETARIA DE ESTADO DA SEGURAN�A PUBLICA");
				report.adicionaCampo(72, 8, "lit_72_8", "C", "", "ESTCC131");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(2, 3);
			{
				report.adicionaCampo(2, 5, "lit_2_5", "C", "", "IDENT");
				report.adicionaCampo(10, 28, "lit_10_28", "C", "", "- INSTITUTO DE IDENTIFICA��O");
				report.adicionaCampo(70, 8, "dataCorrente", "N", "99/99/9999", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(3, 6);
			{
				report.adicionaCampo(2, 32, "lit_2_32", "C", "", "ESTATISTICA DO CADASTRO CRIMINAL");
				report.adicionaCampo(38, 3, "lit_38_3", "C", "", "DE:");
				report.adicionaCampo(44, 8, "Dtini", "N", "99/99/9999", "");
				report.adicionaCampo(56, 1, "lit_56_1", "C", "", "a");
				report.adicionaCampo(59, 8, "Dtfim", "N", "99/99/9999", "");
				report.adicionaCampo(72, 8, "horaCorrente", "S", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(4, 1);
			{
				report.adicionaCampo(2, 1, "lit_2_1", "C", "", "-");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(5, 7);
			{
				report.adicionaCampo(2, 17, "lit_2_17", "C", "", "MATRIC. INCLUSOES");
				report.adicionaCampo(21, 10, "lit_21_10", "C", "", "ALTERACOES");
				report.adicionaCampo(33, 9, "lit_33_9", "C", "", "CORRECOES");
				report.adicionaCampo(44, 6, "lit_44_6", "C", "", "BAIXAS");
				report.adicionaCampo(52, 7, "lit_52_7", "C", "", "EMISSAO");
				report.adicionaCampo(61, 10, "lit_61_10", "C", "", "PRONTUARIO");
				report.adicionaCampo(74, 5, "lit_74_5", "C", "", "TOTAL");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(6, 7);
			{
				report.adicionaCampo(2, 17, "lit_2_17", "C", "", "------- ---------");
				report.adicionaCampo(21, 10, "lit_21_10", "C", "", "----------");
				report.adicionaCampo(33, 9, "lit_33_9", "C", "", "---------");
				report.adicionaCampo(44, 6, "lit_44_6", "C", "", "------");
				report.adicionaCampo(52, 7, "lit_52_7", "C", "", "-------");
				report.adicionaCampo(61, 10, "lit_61_10", "C", "", "----------");
				report.adicionaCampo(74, 5, "lit_74_5", "C", "", "-----");
				report.setFimLinhaRel();
			}

			report.setNumeroRel(2, "D");
			{

				report.setNumeroLinhaRel(7, 8);
				{
					report.adicionaCampo(2, 7, "matricula", "N", "ZZZZZZ9", "");
					report.adicionaCampo(12, 5, "inclusoes", "N", "ZZZZ9", "");
					report.adicionaCampo(22, 5, "alteracoes", "N", "ZZZZ9", "");
					report.adicionaCampo(32, 5, "correcoes", "N", "ZZZZ9", "");
					report.adicionaCampo(42, 5, "baixas", "N", "ZZZZ9", "");
					report.adicionaCampo(52, 5, "ident", "N", "ZZZZ9", "");
					report.adicionaCampo(62, 5, "prontuario", "N", "ZZZZ9", "");
					report.adicionaCampo(72, 5, "total", "N", "ZZZZ9", "");
					report.setFimLinhaRel();
				}

			}

			report.setNumeroRel(3, "D");
			{
				report.setNumeroLinhaRel(57, 8);
				{
					report.adicionaCampo(1, 8, "lit_1_8", "C", "", "--------");
					report.adicionaCampo(11, 7, "lit_11_7", "C", "", "-------");
					report.adicionaCampo(21, 7, "lit_21_7", "C", "", "-------");
					report.adicionaCampo(31, 7, "lit_31_7", "C", "", "-------");
					report.adicionaCampo(41, 7, "lit_41_7", "C", "", "-------");
					report.adicionaCampo(51, 7, "lit_51_7", "C", "", "-------");
					report.adicionaCampo(61, 7, "lit_61_7", "C", "", "-------");
					report.adicionaCampo(71, 7, "lit_71_7", "C", "", "-------");
					report.setFimLinhaRel();
				}
				report.setNumeroLinhaRel(58, 8);
				{
					report.adicionaCampo(2, 7, "lit_2_7", "C", "", "TOTAIS:");
					report.adicionaCampo(11, 6, "matriculat", "N", "ZZZ.ZZ9", "");
					report.adicionaCampo(21, 6, "inclusoest", "N", "ZZZ.ZZ9", "");
					report.adicionaCampo(32, 6, "alteracoest", "N", "ZZZ.ZZ9", "");
					report.adicionaCampo(41, 6, "correcoest", "N", "ZZZ.ZZ9", "");
					report.adicionaCampo(52, 6, "baixast", "N", "ZZZ.ZZ9", "");
					report.adicionaCampo(62, 6, "identt", "N", "ZZZ.ZZ9", "");
					report.adicionaCampo(72, 6, "totalt", "N", "ZZZ.ZZ9", "");
					report.setFimLinhaRel();
				}
			}

		}
	}

	public boolean validar() {
		// validar os campos recebidos da tela
		return true;
	}

	public int getDataCorrente() {
		return dataCorrente;
	}

	public void setDataCorrente(int dataCorrente) throws ParseException {
		this.dataCorrente = dataCorrente;
		report.adicionaValorReport("dataCorrente", dataCorrente);
	}

	public int getDtini() {
		return dtini;
	}

	public void setDtini(int dtini) throws ParseException {
		this.dtini = dtini;
		report.adicionaValorReport("Dtini", dtini);
	}

	public int getDtfim() {
		return dtfim;
	}

	public void setDtfim(int dtfim) throws ParseException {
		this.dtfim = dtfim;
		report.adicionaValorReport("Dtfim", dtfim);
	}

	public int[][] getTra1() {
		return tra1;
	}

	public int getTra1(int index1, int index2) {
		return tra1[index1][index2];
	}

	public void setTra1(int[][] tra1) throws ParseException {
		this.tra1 = tra1;
		report.adicionaValorReport("Tra1", tra1);
	}

	public void setTra1(int index1, int index2, int tra1) throws ParseException {
		this.tra1[index1][index2] = tra1;
		report.adicionaValorReport("Tra1" + "[" + String.valueOf(index1) + "]" + "[" + String.valueOf(index2) + "]", tra1);
	}

	public int[] getMat1() {
		return mat1;
	}

	public void setMat1(int[] mat1) throws ParseException {
		this.mat1 = mat1;
		report.adicionaValorReport("Mat1", mat1);
	}

	public int[] getTot0() {
		return tot0;
	}

	public void setTot0(int[] tot0) throws ParseException {
		this.tot0 = tot0;
		report.adicionaValorReport("Tot0", tot0);
	}

	public int getMat1(int index) {
		return mat1[index];
	}

	public void setMat1(int index, int mat1) throws ParseException {
		this.mat1[index] = mat1;
		report.adicionaValorReport("Mat1" + "[" + String.valueOf(index) + "]", mat1);
	}

	public int getTot0(int index) {
		return tot0[index];
	}

	public void setTot0(int index, int tot0) throws ParseException {
		this.tot0[index] = tot0;
		report.adicionaValorReport("Tot0" + "[" + String.valueOf(index) + "]", tot0);
	}

	public String getHoraCorrente() {
		return horaCorrente;
	}

	public void setHoraCorrente(String horaCorrente) throws ParseException {
		this.horaCorrente = horaCorrente;
		report.adicionaValorReport("horaCorrente", horaCorrente);
	}

	public void setPageSize(int pagesize) throws JRException {
		report.setPageSize(pagesize);
	}

	public void setLineSize(int linesize) {
		report.setLineSize(linesize);
	}

	public int getPageSize() {
		return report.getPageSize();
	}

	public int getPageLine() {
		return report.getPageLine();
	}

	public void saltaLinhas(int qtdLinhas) throws ParseException, JRException {
		report.saltaLinhas(qtdLinhas);
	}

	public void gravaRelatorio(int nroRel) throws ParseException, JRException {
		report.gravaRelatorio(report, nroRel, false);
	}

	public InputStreamDownload imprimir() throws FileNotFoundException, JRException {
		return report.imprimir();
	}

	public int getMatricula() {
		return matricula;
	}

	public void setMatricula(int matricula) throws ParseException {
		this.matricula = matricula;
		report.adicionaValorReport("matricula", matricula);
	}

	public int getInclusoes() {
		return inclusoes;
	}

	public void setInclusoes(int inclusoes) throws ParseException {
		this.inclusoes = inclusoes;
		report.adicionaValorReport("inclusoes", inclusoes);
	}

	public int getAlteracoes() {
		return alteracoes;
	}

	public void setAlteracoes(int alteracoes) throws ParseException {
		this.alteracoes = alteracoes;
		report.adicionaValorReport("alteracoes", alteracoes);
	}

	public int getCorrecoes() {
		return correcoes;
	}

	public void setCorrecoes(int correcoes) throws ParseException {
		this.correcoes = correcoes;
		report.adicionaValorReport("correcoes", correcoes);
	}

	public int getBaixas() {
		return baixas;
	}

	public void setBaixas(int baixas) throws ParseException {
		this.baixas = baixas;
		report.adicionaValorReport("baixas", baixas);
	}

	public int getIdent() {
		return ident;
	}

	public void setIdent(int ident) throws ParseException {
		this.ident = ident;
		report.adicionaValorReport("ident", ident);
	}

	public int getProntuario() {
		return prontuario;
	}

	public void setProntuario(int prontuario) throws ParseException {
		this.prontuario = prontuario;
		report.adicionaValorReport("prontuario", prontuario);
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) throws ParseException {
		this.total = total;
		report.adicionaValorReport("total", total);
	}

	public int getInclusoest() {
		return inclusoest;
	}

	public void setInclusoest(int inclusoest) throws ParseException {
		this.inclusoest = inclusoest;
		report.adicionaValorReport("inclusoest", inclusoest);
	}

	public int getAlteracoest() {
		return alteracoest;
	}

	public void setAlteracoest(int alteracoest) throws ParseException {
		this.alteracoest = alteracoest;
		report.adicionaValorReport("alteracoest", alteracoest);
	}

	public int getCorrecoest() {
		return correcoest;
	}

	public void setCorrecoest(int correcoest) throws ParseException {
		this.correcoest = correcoest;
		report.adicionaValorReport("correcoest", correcoest);
	}

	public int getBaixast() {
		return baixast;
	}

	public void setBaixast(int baixast) throws ParseException {
		this.baixast = baixast;
		report.adicionaValorReport("baixast", baixast);
	}

	public int getIdentt() {
		return identt;
	}

	public void setIdentt(int identt) throws ParseException {
		this.identt = identt;
		report.adicionaValorReport("identt", identt);
	}

	public int getProntuariot() {
		return prontuariot;
	}

	public void setProntuariot(int prontuariot) throws ParseException {
		this.prontuariot = prontuariot;
		report.adicionaValorReport("prontuariot", prontuariot);
	}

	public int getTotalt() {
		return totalt;
	}

	public void setTotalt(int totalt) throws ParseException {
		this.totalt = totalt;
		report.adicionaValorReport("totalt", totalt);
	}

}
